<?php 

class Columns_model extends CI_Model {

	function __construct(){
		parent::__construct();
		$this->load->database();
	}

	public function get_title($id){
		
		$query = $this->db->get_where('column', array('id' => $id));
		return $query->row_array();
	}

	public function get_column($p_id){
		
		$this->db->order_by('id');
		$query = $this->db->get_where('column', array('p_id' => $p_id));
		return $query->result_array();
	}

	public function insert($column, $p_id, $model){
		
		$query = $this->db->insert('column', array('column' => addslashes($column), 'p_id' => $p_id, 'model' => $model));
		return $this->db->affected_rows();
	}

	public function update($id, $column_tile){
		$this->db->where('id', $id);
		$this->db->update('column', array('column' => $column_tile));
		return $this->db->affected_rows();
	}

	public function dele($id){
		$this->db->delete('column', array('id' => $id));
		$this->db->delete('column', array('p_id' => $id));
		return $this->db->affected_rows();
	}
}
